/*
 * Copyright (c) 2020. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
 * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
 * Vestibulum commodo. Ut rhoncus gravida arcu.
 */

package com.shide.businessuser.UI;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bigkoo.pickerview.builder.TimePickerBuilder;
import com.bigkoo.pickerview.listener.CustomListener;
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
import com.bigkoo.pickerview.view.TimePickerView;
import com.contrarywind.view.WheelView;
import com.shide.businessuser.R;
import com.shide.businessuser.Utils.DateUtil_gehj;
import com.shide.businessuser.Utils.MessageEvent;

import org.greenrobot.eventbus.EventBus;

import java.util.Calendar;
import java.util.Date;

public class CustomTimerViewUtils {
    Context mContext;
    Calendar selectedDate = Calendar.getInstance();//系统当前时间
    Calendar startDate = Calendar.getInstance();
    Calendar endDate = Calendar.getInstance();

    public CustomTimerViewUtils(Context context) {
        startDate.set(2000,1,1);
        endDate.set(2060,1,1);
        mContext = context;
    }


    public TimePickerView initTimePicker(TextView tv_display) {
        TimePickerBuilder timePickerBuilder = new TimePickerBuilder(mContext, new OnTimeSelectListener() {
            @Override
            public void onTimeSelect(Date date, View v) {
                tv_display.setText(DateUtil_gehj.date2St_timePicker(date));
                MessageEvent messageEvent = new MessageEvent();
                messageEvent.setCode(MessageEvent.RECORD_REFRESH);
                EventBus.getDefault().post(messageEvent);
            }
        }).setType(new boolean[]{true, true, true, true, true,true})//分别对应年月日时分秒，默认全部显示
                //.setCancelText("Cancel")//取消按钮文字
                //.setSubmitText("Sure")//确认按钮文字

                .setTitleSize(18)
                .setContentTextSize(16)//设置滚轮文字大小
                .setLineSpacingMultiplier(2.5f)//设置行间距
                .setOutSideCancelable(true)//点击屏幕，点在控件外部范围时，是否取消显示
                .isCyclic(true)//是否循环滚动
                .isDialog(true)
                .setTextColorCenter(mContext.getResources().getColor(R.color.blue))//选中的字体的颜色;
                .setDividerColor(mContext.getResources().getColor(R.color.blue))//设置分割线的颜色
                .setTitleBgColor(mContext.getResources().getColor(R.color.white))//标题背景颜色 Night mode
                .setDividerType(WheelView.DividerType.WRAP)
                .setDate(selectedDate)// 如果不设置的话，默认是系统时间*/
                .setRangDate(startDate,endDate)//起始终止年月日设定
                .setLabel("年","月","日","时","分","秒");

        return timePickerBuilder.build();
    }

}
